package day0927_2;

import java.util.Comparator;
import java.util.TreeSet;
class   BJQ  implements Comparator{
    public int compare(Object o1, Object o2) {
        return   ((Child)o1).weight -  ((Child)o2).weight;   //10.172.201.52
    }//o1.值 - o2.值
}
class  Child{  int weight;  }//1.元素
public class C1 {
    public static void main(String[] args) {//2.
        TreeSet<Child>  youErYuan=new TreeSet(  new BJQ() );//2.1.创建一个TreeSet，可以存储其他对象
        Child  lettleRed=new Child(); lettleRed.weight=19; youErYuan.add(lettleRed);//2.2.
        Child  lettlePrety=new Child(); lettlePrety.weight=18; youErYuan.add(lettlePrety); 
        for(Child c:youErYuan){
            System.out.println("c.weight = " + c.weight);
        }
    }
}











